import 'package:flutter/material.dart';
import 'package:livan_ui/values/livan_colors.dart';
import 'package:livan_ui/values/livan_fonts.dart';

class NotPaddingButton extends StatelessWidget {
  final VoidCallback? onPressed;
  final Widget child;

  const NotPaddingButton({
    Key? key,
    required this.onPressed,
    required this.child,
  }):super(key: key);

  @override
  Widget build(BuildContext context) {
    return TextButton(
      style: ButtonStyle(
        padding: MaterialStateProperty.all(EdgeInsets.zero),
      ),
      onPressed: onPressed,
      child: child,
    );
  }
}

class LineWidget extends StatelessWidget {
  final String title;
  final TextStyle? textStyle;
  final Color? borderColor;

  const LineWidget({
    Key? key,
    required this.title,
    this.textStyle,
    this.borderColor,
  }):super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 45,
      decoration: BoxDecoration(
        border: Border.all(color: borderColor ?? ColorsValue.white, width: 1),
        borderRadius: const BorderRadius.all(Radius.circular(22)),
      ),
      child: Center(
        child: Text(
          title,
          style: textStyle ??
              TextStyle(
                color: borderColor ?? ColorsValue.white,
                fontSize: Font.font16,
              ),
        ),
      ),
    );
  }
}

class LineButton extends StatelessWidget {
  final String title;
  final TextStyle? textStyle;
  final Color? borderColor;
  final VoidCallback? onPressed;

  const LineButton({
    Key? key,
    required this.title,
    this.textStyle,
    this.borderColor,
    this.onPressed,
  }):super(key: key);

  @override
  Widget build(BuildContext context) {
    return NotPaddingButton(
      onPressed: onPressed,
      child: LineWidget(
        title: title,
        textStyle: textStyle,
        borderColor: borderColor,
      ),
    );
  }
}

class FillButton extends StatelessWidget {
  final String title;
  final TextStyle? textStyle;
  final List<Color>? gradientColor;
  final VoidCallback? onPressed;
  final bool enable;

  const FillButton({
    Key? key,
    required this.title,
    this.textStyle,
    this.gradientColor,
    this.onPressed,
    this.enable = true,
  }):super(key: key);

  @override
  Widget build(BuildContext context) {
    return NotPaddingButton(
      onPressed: enable ? onPressed : ()=>{},
      child: FillWidget(
        enable: enable,
        title: title,
        textStyle: textStyle,
        gradientColor: gradientColor,
      ),
    );
  }
}

class FillWidget extends StatelessWidget {
  final String title;
  final TextStyle? textStyle;
  final List<Color>? gradientColor;
  final bool enable;

  const FillWidget({
    Key? key,
    required this.title,
    this.textStyle,
    this.gradientColor,
    this.enable = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final enableStyle =
        textStyle ?? TextStyle(color: ColorsValue.white, fontSize: Font.font16);
    final disableStyle =
    TextStyle(color: ColorsValue.textGrey, fontSize: Font.font16);
    final disableGradient = LinearGradient(
        colors: [Color(0xFFDFDFDD), Color(0xFFDFDFDD)]);
    final enableGradient = LinearGradient(colors: gradientColor ?? []);
    return Container(
      alignment: Alignment.center,
      height: 45,
      decoration: BoxDecoration(
        gradient: enable ? enableGradient : disableGradient,
        borderRadius: BorderRadius.all(Radius.circular(22)),
      ),
      child: Text(
        title,
        style: enable ? enableStyle : disableStyle,
      ),
    );
  }
}
